package com.reindeer.controller;

import com.reindeer.common.JsonResult;
import com.reindeer.dto.LoginDTO;
import com.reindeer.vo.UserVO;
import com.reindeer.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@CrossOrigin(origins = "*")
@RestController
@RequestMapping("/user")
public class SysUserController {

    @Autowired
    private SysUserService sysUserService;

    @PostMapping("/login")
    public JsonResult<UserVO> login(@RequestBody @Valid LoginDTO loginDTO) {
        UserVO userVO = sysUserService.login(loginDTO);
        return JsonResult.success(userVO);
    }
} 